home *** CD-ROM | disk | FTP | other *** search
/ Night Owl 6 / Night Owl's Shareware - PDSI-006 - Night Owl Corp (1990).iso / 039a / mawk10.zip / TYPES.H < prev    next >
C/C++ Source or Header  |  1991-10-05  |  3KB  |  137 lines

  1.  
  2. /********************************************
  3. types.h
  4. copyright 1991, Michael D. Brennan
  5.  
  6. This is a source file for mawk, an implementation of
  7. the AWK programming language.
  8.  
  9. Mawk is distributed without warranty under the terms of
  10. the GNU General Public License, version 2, 1991.
  11. ********************************************/
  12.  
  13.  
  14. /* $Log:    types.h,v $
  15.  * Revision 3.3.1.1  91/09/14  17:24:27  brennan
  16.  * VERSION 1.0
  17.  * 
  18.  * Revision 3.3  91/08/13  06:52:16  brennan
  19.  * VERSION .9994
  20.  * 
  21.  * Revision 3.2  91/06/28  04:17:43  brennan
  22.  * VERSION 0.999
  23.  * 
  24.  * Revision 3.1  91/06/07  10:28:27  brennan
  25.  * VERSION 0.995
  26.  * 
  27.  * Revision 2.4  91/06/04  06:48:40  brennan
  28.  * type to store parse table mem usage
  29.  * 
  30.  * Revision 2.3  91/05/28  09:05:21  brennan
  31.  * removed main_buff
  32.  * 
  33.  * Revision 2.2  91/05/16  12:20:28  brennan
  34.  * cleanup of machine dependencies
  35.  * 
  36.  * Revision 2.1  91/04/08  08:24:15  brennan
  37.  * VERSION 0.97
  38.  * 
  39. */
  40.  
  41.  
  42. /*  types.h  */
  43.  
  44. #ifndef  TYPES_H
  45. #define  TYPES_H
  46.  
  47. #if     HAVE_VOID_PTR
  48. typedef  void *PTR ;
  49. #else
  50. typedef  char *PTR ;
  51. #endif
  52.  
  53. #include  "sizes.h"
  54.  
  55.  
  56. /*  CELL  types  */
  57.  
  58. #define  C_NOINIT                0
  59. #define  C_DOUBLE                1
  60. #define  C_STRING                2
  61. #define  C_STRNUM                3
  62. #define  C_MBSTRN                4 
  63.         /*could be STRNUM, has not been checked */
  64. #define  C_RE                    5
  65. #define  C_SPACE                 6
  66.         /* split on space */
  67. #define  C_SNULL                 7
  68.         /* split on the empty string  */
  69. #define  C_REPL                  8
  70.         /* a replacement string   '\&' changed to &  */
  71. #define  C_REPLV                 9
  72.         /* a vector replacement -- broken on &  */
  73. #define  NUM_CELL_TYPES         10
  74.  
  75. /* these defines are used to check types for two
  76.    CELLs which are adjacent in memory */
  77.  
  78. #define  TWO_NOINITS  (2*(1<<C_NOINIT))
  79. #define  TWO_DOUBLES  (2*(1<<C_DOUBLE))
  80. #define  TWO_STRINGS  (2*(1<<C_STRING))
  81. #define  TWO_STRNUMS  (2*(1<<C_STRNUM))
  82. #define  TWO_MBSTRNS  (2*(1<<C_MBSTRN))
  83. #define  NOINIT_AND_DOUBLE  ((1<<C_NOINIT)+(1<<C_DOUBLE))
  84. #define  NOINIT_AND_STRING  ((1<<C_NOINIT)+(1<<C_STRING))
  85. #define  NOINIT_AND_STRNUM  ((1<<C_NOINIT)+(1<<C_STRNUM))
  86. #define  DOUBLE_AND_STRING  ((1<<C_DOUBLE)+(1<<C_STRING))
  87. #define  DOUBLE_AND_STRNUM  ((1<<C_STRNUM)+(1<<C_DOUBLE))
  88. #define  STRING_AND_STRNUM  ((1<<C_STRING)+(1<<C_STRNUM))
  89. #define  NOINIT_AND_MBSTRN  ((1<<C_NOINIT)+(1<<C_MBSTRN))
  90. #define  DOUBLE_AND_MBSTRN  ((1<<C_DOUBLE)+(1<<C_MBSTRN))
  91. #define  STRING_AND_MBSTRN  ((1<<C_STRING)+(1<<C_MBSTRN))
  92. #define  STRNUM_AND_MBSTRN  ((1<<C_STRNUM)+(1<<C_MBSTRN))
  93.  
  94. typedef  struct {
  95. unsigned short ref_cnt ;
  96. unsigned short len ;
  97. char str[4] ;
  98. } STRING ;
  99.  
  100.  
  101. typedef  struct cell {
  102. short type ;
  103. short vcnt ; /* only used if type == C_REPLV   */
  104. PTR   ptr ;
  105. double  dval ;
  106. }  CELL ;
  107.  
  108.  
  109. /* all builtins are passed the evaluation stack pointer and
  110.    return its new value, here is the type */
  111.  
  112. #if    HAVE_PROTOS
  113. typedef CELL *(*PF_CP)(CELL *) ;
  114. #else
  115. typedef CELL *(*PF_CP)() ;
  116. #endif
  117.  
  118. /* an element of code (instruction) */
  119. typedef  union {
  120. int  op ;
  121. PTR  ptr ;
  122. }  INST ;
  123.  
  124. /* a scratch buffer type */
  125. union tbuff {
  126. PTR   ptr_buff[MAX_SPLIT] ;
  127. char   string_buff[SPRINTF_SZ] ;
  128. } ;
  129.  
  130. /* how we give parser table memory to zmalloc */
  131. struct yacc_mem {
  132. PTR mem ;
  133. short zblocks ;
  134. } ;
  135.  
  136. #endif
  137.